### This script creates a final dataset with a measure of strategic 
### industries based on Chinese policy documents. 

rm(list = ls())
setwd("/Users/John/Dropbox/")

# --- Load Required Packages ---

library(readr)
library(readxl)
library(tidyverse)

# --- Load Dataset ---

df <- as.data.frame(read_csv("JOP_Replication_Materials/data/processed/final_dataset.csv"))

# --- Alternative Measure of Strategic Industry - Chinese Policies ---

alt_strategic <- as.data.frame(read_excel("JOP_Replication_Materials/appendix/data/cn_policies_strategic.xlsx", 
                                                 sheet = "shortlist_isic_codes"))

colnames(alt_strategic)[1] <- "isic"
alt_strategic$alt_strategic <- 1
df$isic <- as.character(df$isic)
alt_strategic$isic <- as.character(alt_strategic$isic)

df <- left_join(df, alt_strategic, by = c("isic" = "isic"))

df$alt_strategic[is.na(df$alt_strategic)] <- 0


# --- Save File ---

write.csv(df, "JOP_Replication_Materials/appendix/data/final_dataset_alt_strategic.csv")


